#Appendix D

############Robustness 
#Marginal means: Potential defined with PTV > 5 only
mm_pot_ptv <- cj(df3, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                   Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm")
#Plot
cj1_pot_ptv<-plot(mm_pot_ptv, vline = 0.5, size=5) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.4, 0.6), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        12) + theme(text=element_text(family="Garamond", size=22))+
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold')))+
  guides(fill = guide_legend(override.aes = list(color = NA)),
         color = FALSE,
         shape = FALSE) + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))



#marginal means
#Potential defined with PTV>6 OR a left-right self placement of <5
mm_pot_ptv_lrs <- cj(df4, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                       Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm")

#Plot
cj1_pot_ptv_lrs<-plot(mm_pot_ptv_lrs, vline = 0.5, size=5) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.35, 0.65), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        12) + theme(text=element_text(family="Garamond", size=22))+
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) +
  guides(fill = guide_legend(override.aes = list(color = NA)),
         color = FALSE,
         shape = FALSE) + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))




############
#Potential defined with left-right self placement of <5 only
mm_pot_lrs <- cj(df5, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                   Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm")
#Plot
cj_pot_lrs<-plot(mm_pot_lrs, vline = 0.5, size=5) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.35, 0.65), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        12) + theme(text=element_text(family="Garamond", size=22)) +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) +
  guides(fill = guide_legend(override.aes = list(color = NA)),
         color = FALSE,
         shape = FALSE) + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))



#Marginal means: Potential defined with PTV > 5 only
#marginal means classes
mm_pot_ptv_class <- cj(df3, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                         Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~oesch)

#Plot
cj_pot_ptv_class<-plot(mm_pot_ptv_class,group = "oesch", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.35, 0.65), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        12) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Class")) + theme(legend.position="bottom")   +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) 
cj_class_2a$data <- cj_pot_ptv_class$data[c(100:114, 133:147, 199:213,115:132, 148:165, 214:231),]



#Potential defined with PTV>6 OR a left-right self placement of <5
#classes
mm_pot_ptv_lrs_class <- cj(df4, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                             Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~oesch)

#Plot
cj_pot_ptv_lrs_class<-plot(mm_pot_ptv_lrs_class,group = "oesch", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.35, 0.65), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        12) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Class")) + theme(legend.position="bottom")   +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) 

#Select relevant classes
cj_pot_ptv_lrs_class$data <- cj_pot_ptv_lrs_class$data[c(100:114, 133:147, 199:213,115:132, 148:165, 214:231),]




#Potential defined with left-right self placement of <5 only
#class
mm_pot_lrs_class <- cj(df5, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                         Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~oesch)

#Plot
cj_pot_lrs_class<-plot(mm_pot_lrs_class,group = "oesch", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.35, 0.65), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        12) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Class")) + theme(legend.position="bottom")   +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) 

cj_pot_lrs_class$data <- cj_pot_lrs_class$data[c(100:114, 133:147, 199:213,115:132, 148:165, 214:231),]



#Marginal means: Potential defined with PTV > 5 only
#mm for educ_groups
mm_pot_ptv_educ <- cj(df3, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                        Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~educ_2)

#Plot
cj_pot_ptv_educ<-plot(mm_pot_ptv_educ,group = "educ_2", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.35, 0.65), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        15) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Educational Groups")) + theme(legend.position="bottom")   +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) 






#Potential defined with PTV>6 OR a left-right self placement of <5
#mm for educ_groups
mm_pot_ptv_lrs_educ <- cj(df4, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                            Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~educ_2)

#Plot
cj_pot_ptv_lrs_educ<-plot(mm_pot_ptv_lrs_educ,group = "educ_2", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.35, 0.65), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        15) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Educational Groups")) + theme(legend.position="bottom")   +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) 

#Potential defined with left-right self placement of <5 only
#mm for educ_groups
mm_pot_lrs_educ <- cj(df5, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                        Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~educ_2)

#Plot
cj_pot_lrs_educ<-plot(mm_pot_lrs_educ,group = "educ_2", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.35, 0.65), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        15) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Educational Groups")) + theme(legend.position="bottom")   +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) 



#Marginal means: Potential defined with PTV > 5 only
#mm for educ_groups
mm_pot_ptv_age <- cj(df3, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                       Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~age_groups)

#Plot
cj_pot_ptv_age<-plot(mm_pot_ptv_age,group = "age_groups", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.35, 0.65), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        15) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Age Groups")) + theme(legend.position="bottom")   +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) 



#Potential defined with PTV>6 OR a left-right self placement of <5
#mm for age groups
mm_pot_ptv_lrs_age  <- cj(df4, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                            Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~age_groups)

#Plot
cj_pot_ptv_lrs_age<-plot(mm_pot_ptv_lrs_age,group = "age_groups", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.35, 0.65), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        15) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Age Groups")) + theme(legend.position="bottom")   +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) 


#Potential defined with left-right self placement of <5 only
#mm for educ_groups
mm_pot_lrs_age <- cj(df5, choice ~ Immigration + Headscarf + Gender_quota + Ecology + Childcare +
                       Early_retirement + Inheritance_tax + Job_protection + Housing,  id = ~respondentid, estimate = "mm", by = ~age_groups)

#Plot
cj_pot_lrs_age<-plot(mm_pot_lrs_age,group = "age_groups", vline = 0.5, size=3) +
  geom_point(position = position_dodge(0.75)) +
  scale_x_continuous(limits = c(0.35, 0.65), breaks = c(0.3, 0.4, 0.5, 0.6, 0.7)) +
  theme_bw() + xlab("Marginal Means") + theme_minimal(base_size =
                                                        15) + theme(text=element_text(family="Garamond", size=22))+
  guides(color=guide_legend("Age Groups")) + theme(legend.position="bottom")   +
  geom_hline(yintercept = hlines_values, color = "black", linetype = "dashed") + 
  scale_y_discrete(labels = function(x) gsub("_", " ", gsub("\\(|\\)", "", x)))  +
  theme(text=element_text(face = c('plain', 'plain','plain','bold',
                                   'plain', 'plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain','plain','bold',
                                   'plain', 'plain', 'bold',
                                   'plain', 'plain', 'plain','bold'))) 
